import "package:ct_pa_majordomo/config/theme_vars.dart";
import "package:ct_pa_majordomo/pages/device/lock/password_key/widgets/get_key/tab_pane.dart";
import "package:flutter/cupertino.dart";
import "package:flutter/material.dart";

class GetKey extends StatefulWidget {
  final Map lockInfo;
  const GetKey({super.key,  required this.lockInfo});

  @override
  State<StatefulWidget> createState() => _GetKeyState();

}

class _GetKeyState extends State<GetKey> {
  final List _tabs = ["限时", "单次", "永久", "自定义", "清空码", "循环"];
  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      length: _tabs.length,
      child: Scaffold(
        appBar: AppBar(
          iconTheme: const IconThemeData(color: Colors.white),
          title: const Text("获取密码", style: TextStyle(color: Colors.white),),
          centerTitle: true,
          backgroundColor: ThemeVars.colorPrimaryDark,
          leading: IconButton(
            icon: const Icon(Icons.arrow_back_ios_new),
            onPressed: () {
              Navigator.pop(context);
            },
          ),
          bottom: PreferredSize(
            preferredSize: const Size.fromHeight(48),
            child: Material(
              color: Colors.white,
              child: TabBar(
                // isScrollable: true,
                // tabAlignment: TabAlignment.center,
                tabs: List.generate(_tabs.length, (index) => Tab(text: _tabs[index],)),
              ),
            )
          ),
        ),
        body: TabBarView(
          children: [
            TabPane(usageTimeType: UsageTimeType.usage, lockInfo: widget.lockInfo,),
            TabPane(usageTimeType: UsageTimeType.single, lockInfo: widget.lockInfo,),
            TabPane(usageTimeType: UsageTimeType.forever, lockInfo: widget.lockInfo,),
            TabPane(usageTimeType: UsageTimeType.custom, lockInfo: widget.lockInfo,),
            TabPane(usageTimeType: UsageTimeType.clear, lockInfo: widget.lockInfo,),
            TabPane(usageTimeType: UsageTimeType.cycle, lockInfo: widget.lockInfo,),
          ]
        ),
      ),
    );
  }

}